﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Plot.Primitives
{
    internal class Axis : PShape
    {
        public double Length { get; set; }
        public double DividerDistance { get; set; }

        public Axis(double x, double y, double angle, double length, double dividerDistance)
            : base(x, y, angle)
        {
            Length = length;
            DividerDistance = dividerDistance;
        }

        public override IEnumerator<PShape> GetEnumerator()
        {
            return new ReadOnlyCollection<PShape>(new PShape[] {
                                                                   new PLine(StartPoint.X, StartPoint.Y, StartPoint.X + Length, StartPoint.Y) {PivotPoint = StartPoint, Angle = Angle},
                                                                   new AxisDivider(StartPoint.X, StartPoint.Y, 0d, DividerDistance, ((int) Length / (int) DividerDistance), 5d, 0d) {PivotPoint = StartPoint, Angle = Angle},
                                                                   new AxisArrow(StartPoint.X + Length, StartPoint.Y, 10d, 10d, 0d) {PivotPoint = StartPoint, Angle = Angle}
                                                               }).GetEnumerator();
        }
    }
}